import java.util.ArrayList;
import java.util.Random;

import com.acme.bankapp.domain.bank.Bank;
import com.acme.bankapp.domain.bank.ClientRegistrationListener;
import com.acme.bankapp.service.bank.BankService;
import com.acme.exceptions.*;

public class BankApplication {
  public static void main(String[] args){
    Bank bank;
    try{
      bank = new Bank(new ArrayList<ClientRegistrationListener>());
    }
    catch(OverDraftLimitExceededException e){
      System.out.println("Cannot create an instance of Bank;");
      System.out.println("Maximum possible payout for a client is: " + e.getMaxPossiblePayout());
      return;
    }
    catch(BankException e){
      System.out.println("Cannot create an instance of Bank;");
      System.out.println(e.getMessage());
      return;
    }
    modifyBank(bank);
    BankService.printMaximumAmountToWithDraw(bank);
  }
  static void modifyBank(Bank bank){
    Random rand = new Random();
    for(int i=0; i<bank.getClients().size(); i++){
      for(int j=0; j<bank.getClients().get(i).getAcconts().size(); j++){
        bank.getClients().get(i).getAcconts().get(j).deposit(rand.nextInt(100));
      }
    }
  }
  static void printBalance(Bank bank){
    for(int i=0; i<bank.getClients().size(); i++){
      for(int j=0; j<bank.getClients().get(i).getAcconts().size(); j++){
        System.out.println(bank.getClients().get(i).getAcconts().get(j).getBalance());
      }
    }
  }
  static void printClientSalutations(Bank bank){
    for(int i=0; i<bank.getClients().size(); i++){
      bank.getClients().get(i).getClientSaltation();
    }
  }
}
